/**
 * 
 */
package com.org.javabody.extendsApi.extendsDemo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * extends 
 * 父类中的方法声明为abstract(抽象类)时，子类必须要继承该类(这点跟接口实现相类似)
 * @author Administrator
 *
 */

abstract class Animal {
	private final static Logger log = LoggerFactory.getLogger(Animal.class); 
	public abstract void eat();
    public void fly(){
    	log.info("所有的动物都会飞么?");
    }
    public void swimming(){
    	log.info("所有的动物都会游泳么?");
    }
}

class Person extends Animal{
	private final static Logger log = LoggerFactory.getLogger(Person.class); 
	@Override
	public void eat() {
		log.info("人杂食性...");
	}	
	public void swimming(){
		log.info("后天学习才能学会游泳...");
	}
}

class Duck extends Animal{
	private final static Logger log = LoggerFactory.getLogger(Duck.class); 
	@Override
	public void eat() {
		log.info("鸭杂食性...");
	}	
	public void fly() {
		log.info("有翅膀却不会飞...");
	}
	public void swimming() {
		log.info("天生就会游泳...");
	}
	
}

public class ExtendsDemo {

	/**

	 * @param args

	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub


		  Long a = System.currentTimeMillis();
          Animal animal1 = new Person();//访问父类中的方法

          animal1.eat();
          animal1.fly();
          animal1.swimming();
          Animal animal2 = new Duck();
          animal2.eat();
          animal2.fly();
          animal2.swimming();
          
          new Person().eat();
          new Person().swimming();
          new Person().fly();
          Long b = System.currentTimeMillis();
          System.out.print((b-a)+"ms");
	}

}
